package com.searchparking.BUS;



import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.view.View;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class MyItemizedOverlay extends ItemizedOverlay<OverlayItem>{
	private ArrayList<OverlayItem> overlayItemList = new ArrayList<OverlayItem>();
	Context context;
	
	public MyItemizedOverlay(Drawable marker, Context c) {
		super(boundCenterBottom(marker));
		// TODO Auto-generated constructor stub
		populate();
		context = c;
		}
	
	public MyItemizedOverlay(Drawable marker) {
		super(boundCenterBottom(marker));
		populate();
		// TODO Auto-generated constructor stub
	}
	
	public void addItem(GeoPoint p, String title, String snippet){
		OverlayItem newItem = new OverlayItem(p, title, snippet);
		overlayItemList.add(newItem);
		   populate();
		}

	
	//Click to add 1 new marker
/*	public boolean onTap(GeoPoint p, MapView mapView) {
		 // TODO Auto-generated method stub
		  
		 if(super.onTap(p, mapView)) {
			 	return true;
		 }//If marker on location isset then not new create
		  
		 String title = "pt:" + String.valueOf(overlayItemList.size() + 1);
		 String snippet = "geo:\n"
		   + String.valueOf(p.getLatitudeE6()) + "\n"
		   + String.valueOf(p.getLongitudeE6());
		  
		 addItem(p, title, snippet);
		  
		 return true;
		}*/
	@Override
	protected OverlayItem createItem(int i) {
		// TODO Auto-generated method stub
		return overlayItemList.get(i);
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return overlayItemList.size();
	}
	public void draw(Canvas canvas, MapView mapView, boolean shadow,GeoPoint p) {
		// TODO Auto-generated method stub
		super.draw(canvas, mapView, shadow);
		//boundCenterBottom(marker);
		Paint paint = new Paint();
		canvas.drawText("hehe",p.getLatitudeE6(),p.getLongitudeE6(), paint);
		}
}
